package com.team.mapper;

import com.team.dto.TeamPageQueryDTO;
import com.team.entity.Team;
import com.github.pagehelper.Page;
import com.team.entity.TeamDetails;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TeamMapper {
    /**
     * 分页查询
     * @param teamPageQueryDTO 分页查询条件
     * @return 分页结果
     */
    Page<Team> page(TeamPageQueryDTO teamPageQueryDTO);

    /**
     * 直接查询所有团队
     * @return
     */
    @Select("select * from teams")
    List<Team> getAll();

    /**
     * 查询某团队的详情
     * @param tid
     * @return
     */
    @Select("select * from team_details where tid=#{tid}")
    TeamDetails getTeamDetails(Integer tid);

    /**
     * 查询队长对应的团队
     * @param applicantId
     * @return
     */
    @Select("select tid from team_leader where student_id=#{applicantId}")
    Integer getTid(int applicantId);

    /**
     * 根据tid查询团队名称
     * @param tid
     * @return
     */
    @Select("select name from teams where tid=#{tid}")
    String getName(Integer tid);
}
